﻿using System.Collections.Generic;
using System.Data;

namespace Luna.Data.Common
{
    /// <summary>
    /// Mapper for data interface ISearchData.
    /// </summary>
    public partial class SearchDataMapper
    {
        private const string DefaultSearchRequest = "Meta.search_search";

        private const string TokenColumnName = "token";
        private const string RowsColumnName = "rows";

        public string SearchRequest { get; set; }

        partial void Initialize()
        {
            SearchRequest = DefaultSearchRequest;
        }

        public IEnumerable<ISearchData> Search(IDbTransaction transaction, string token, int rows)
        {
            return ExecuteGetAll(
                    transaction,
                    SearchRequest,
                    c =>
                    {
                        c.AddParameter(TokenColumnName, token);
                        c.AddParameter(RowsColumnName, rows);
                    });
        }
    }
}